<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 perl_modules.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
$page_title = "Perl Modules Installed";
include $root_path.'common.php';
include $root_path.'page_header.php';



$perl_modules_data = "<cpanel Serverinfo="linkedperlmodules()">";

$perl_modules_data = str_replace('<tr>', '', $perl_modules_data);
$perl_modules_data = str_replace('</tr>', '', $perl_modules_data);
$perl_modules_data = str_replace('<td>', '', $perl_modules_data);
$perl_modules_data = str_replace("\n", '', $perl_modules_data);


//
// Let's split it up into items
//
$array_of_items = explode('</td>', $perl_modules_data);

//
// Alphabetical order
//

array_multisort($array_of_items);


//
// Annoyingly, cpanel has duplicates of modules. Here we filter them out.
//
$array_of_modules = array();
$previous_item = '';
$i = 0;
foreach($array_of_items as $module) {

	if ($module != $previous_item and !empty($module)) {
		$array_of_modules[$i] = $module;
		$i++;
	}
	$previous_item = $module;
}



//
// OK, let's template this sucker!
//
$perl_columns = $template_cfg['perl_columns'];
$number_of_modules = count($array_of_modules);
$number_per_column = intval($number_of_modules/$perl_columns);


$template->set_filenames(array(
	'body' => $root_path.$template_path.'server/perl_modules.tpl')
);

$i=0;
$columns_made=0;
foreach ($array_of_modules as $row) {
	if (($i==0 or $i==$number_per_column) and $columns_made<$perl_columns) {
		$template->assign_block_vars('modulecol', array()
		);
		$i=0;
		$columns_made++;
	}
	$i++;
	$template->assign_block_vars('modulecol.modulerow', array(
		'NAME' => $row
		)
	);
	
}

$template->pparse('body');




include $root_path.'page_tail.php';

?>

